package org.example.myleet.rosalind.utils;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class NewickTreeNode {

    private int id;

    private int weight;

    private String value;

    private NewickTreeNode parent;

    private List<NewickTreeNode> children;

    private int childrenLabelCount = 0;

    private BigInteger qHere = BigInteger.ZERO;

    public NewickTreeNode(int id, int weight, String value, NewickTreeNode parent) {
        this.id = id;
        this.weight = weight;
        this.value = value;
        this.parent = parent;
        this.children = new ArrayList<>();
    }

    public int getId() {
        return id;
    }

    public int getWeight() {
        return weight;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public NewickTreeNode getParent() {
        return parent;
    }

    public List<NewickTreeNode> getChildren() {
        return children;
    }

    public int getChildrenLabelCount() {
        return childrenLabelCount;
    }

    public void setChildrenLabelCount(int childrenLabelCount) {
        this.childrenLabelCount = childrenLabelCount;
    }

    public BigInteger getqHere() {
        return qHere;
    }

    public void setqHere(BigInteger qHere) {
        this.qHere = qHere;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        NewickTreeNode node = (NewickTreeNode) o;
        return id == node.id;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("NewickTreeNode{");
        sb.append("id=").append(id);
        sb.append(", value='").append(value).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
